import request from '@/utils/request'
import { downFile } from '@/utils/request'

/**
 * 订单主表分页查询
 * @param {查询条件} data
 */
export function listLayOrder(query) {
  return request({
    url: 'business/LayOrder/list',
    method: 'get',
    params: query,
  })
}

/**
 * 新增订单主表
 * @param data
 */
export function addLayOrder(data) {
  return request({
    url: 'business/LayOrder',
    method: 'post',
    data: data,
  })
}
/**
 * 修改订单主表
 * @param data
 */
export function updateLayOrder(data) {
  return request({
    url: 'business/LayOrder',
    method: 'PUT',
    data: data,
  })
}
/**
 * 退款提交数据
 * @param {*} data 
 * @returns 
 */
export function LayOrderAddRefund(data) {
  return request({
    url: 'business/LayOrder/AddRefund',
    method: 'post',
    data: data,
  })
}

/**
 * 退款提交数据
 * @param {*} data 
 * @returns 
 */
export function LayOrderOut(data) {
  return request({
    url: 'business/LayOrder/LayOrderOut',
    method: 'post',
    data: data,
  })
}
/**
 * 
 * @param {*} data 
 * @returns 
 */
export function LayOrderCheckIn(data) {
  return request({
    url: 'business/LayOrder/CheckIn',
    method: 'post',
    data: data,
  })
}
/**
 * 
 * @param {商家接单或取消订单} data 
 * @returns 
 */
export function LayOrderConfirm(data) {
  return request({
    url: 'business/LayOrder/LayOrderConfirm',
    method: 'post',
    data: data,
  })
}
/**
 * 获取订单主表详情
 * @param {Id}
 */
export function getLayOrder(id) {
  return request({
    url: 'business/LayOrder/' + id,
    method: 'get'
  })
}
/**
 * 获取订单销售走势图
 * 
 */
export async function LayOrderSalesTrend() {
  return await request({
    url: 'business/LayOrder/LayOrderSalesTrend',
    method: 'get'
  })
}

/**
 * 获取订单销售走势图
 * 
 */
export async function LayOrderNowYear() {
  return await request({
    url: 'business/LayOrder/LayOrderNowYear',
    method: 'get'
  })
}
/**
/**
 * 获取订单主表详情
 * @param {Id}
 */
export function getOrderById(id) {
  return request({
    url: 'business/LayOrder/GetOrderById?id=' + id,
    method: 'get'
  })
}
/**
 * 删除订单主表
 * @param {主键} pid
 */
export function delLayOrder(pid) {
  return request({
    url: 'business/LayOrder/delete/' + pid,
    method: 'POST'
  })
}
// 导出订单主表
export async function exportLayOrder(query) {
  await downFile('business/LayOrder/export', { ...query })
}
